package com.example.smart.adapter.home

import android.app.Activity
import android.view.LayoutInflater
import android.view.ViewGroup
import com.example.lib.extend.setOnDoubleClickListener
import com.example.smart.R
import com.example.smart.base.adapter.BaseRecyclerAdapter
import com.example.smart.base.adapter.BaseViewHolder
import com.example.smart.databinding.ItemFindPreventionBinding
import com.example.smart.utils.DisplayUtils

class FindPreventionAdapter(val activity: Activity) : BaseRecyclerAdapter<ItemFindPreventionBinding, Int>(activity,
    mutableListOf(R.mipmap.icon_find1, R.mipmap.icon_find2, R.mipmap.icon_find3)) {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<ItemFindPreventionBinding> {
        return BaseViewHolder(ItemFindPreventionBinding.bind(LayoutInflater.from(context)
            .inflate(R.layout.item_find_prevention, parent, false)))
    }

    override fun onBindView(itemView: ItemFindPreventionBinding, bean: Int, position: Int) {
        itemView.root.setImageResource(bean)
        itemView.root.setOnDoubleClickListener {
            DisplayUtils.toPreventionDetails(activity)
        }
    }
}